package com.wish.controller;


import com.github.pagehelper.PageInfo;
import com.wish.dto.TsfContractDto;
import com.wish.entity.TSfContract;
import com.wish.entity.TSfTermination;
import com.wish.service.ITSfContractService;
import com.wish.service.ITSfFinalStatementDetailService;
import com.wish.service.ITSfTerminationService;
import com.wish.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 五组
 * @since 2021-03-29
 */
@RestController
@RequestMapping("/wish/t-sf-contract")
public class TSfContractController {

    @Autowired
    ITSfContractService itSfContractService;

    @Autowired
    ITSfTerminationService itSfTerminationService;

    @Autowired
    ITSfFinalStatementDetailService itSfFinalStatementDetailService;

    //收房列表查询
    @RequestMapping("list")
    public ResultEntity list(TsfContractDto tsfContractDto){

        PageInfo<TSfContract> list = itSfContractService.getlist(tsfContractDto);
        System.out.print(list);
        return ResultEntity.ok("200","成功",list);

    }

    //业主列表查询
    @RequestMapping("yezhulist")
    public ResultEntity yezhulist(TsfContractDto tsfContractDto){

        PageInfo<TSfContract> list = itSfContractService.getlists(tsfContractDto);

        return ResultEntity.ok("200","成功",list);

    }

    //解约列表查询
    @RequestMapping("jie")
    public ResultEntity jie(TsfContractDto tsfContractDto){
        PageInfo<TSfContract> ss = itSfContractService.jie(tsfContractDto);
        return ResultEntity.ok("200","成功",ss);
    }

    //解约中的收房合同回显
    @RequestMapping("getOne")
    public TSfContract getOne(Long id){
        System.out.println(id+"======");
        TSfContract tSfContract = itSfContractService.getById(id);
        return tSfContract;
    }

    @RequestMapping("add")
    public boolean add(@RequestBody TSfContract tSfContract){
        try{
            itSfContractService.save(tSfContract);
            return true;
        }catch (Exception e){
            return false;
        }
    }

}
